package com.echo.week.io.chat;

import java.util.Scanner;

/**
 * @Author echo
 * @Description
 * @Date 2023/10/22.
 * @Version 1.0
 */
public class TestChat {
    public static void main(String[] args) throws Exception {
        ChatClient chatClient=new ChatClient();
        new Thread(() -> {
            //监听服务器消息
            while(true){
                try {
                    chatClient.receiveMsg();
                    Thread.sleep(2000);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }).start();
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNextLine()){
            String msg=scanner.nextLine();
            chatClient.sendMsg(msg);
        }
    }

}
